/*
 * Rubber.java
 *
 * Created on 9 maj 2007, 18:33
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package pl.krakow.ae.knp.wikiboard.gui.tools.transformers;

import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import pl.krakow.ae.knp.wikiboard.gui.board.Board;
import pl.krakow.ae.knp.wikiboard.gui.board.BoardEvent;
import pl.krakow.ae.knp.wikiboard.gui.drawables.Drawable;

/**
 *
 * @author m
 */
public class Rubber extends Transformer {
    Drawable drawable;
    
    /** Creates a new instance of Rubber */
    public Rubber() {
    }
    
    public BoardEvent createEvent() {
        return new BoardEvent(drawable, null);
    }
    
    public void mousePressed(MouseEvent event, Graphics2D g) {
        Iterator<Drawable> it = Board.drawablesList.iterator();
        while(it.hasNext()) {
            Drawable d = it.next();
            if (d.contains(event.getPoint()))
                drawable = d;
        }
        
        BoardEvent e = createEvent();
        processBoardEvent(e);
    }
    
    public void mouseDragged(MouseEvent event, Graphics2D g) {
    }
    
    public void mouseReleased(MouseEvent event, Graphics2D g) {
    }
    
    public Drawable getDrawable() {
        return drawable;
    }
    
}
